package cn.com.czpb.client.module.personal.acticity;//package cn.com.gxrb.client.module.personal.acticity;
//
//import android.content.Intent;
//import android.os.Bundle;
//import android.view.View;
//import android.widget.AdapterView;
//import android.widget.ListView;
//import android.widget.TextView;
//
//import com.handmark.pulltorefresh.library.PullToRefreshBase;
//import com.handmark.pulltorefresh.library.PullToRefreshListView;
//import cn.com.gxrb.client.R;
//import cn.com.gxrb.client.app.ToolBarActivity;
//import cn.com.gxrb.client.model.news.NewsBean;
//import cn.com.gxrb.client.model.usercenter.ComBean;
//import cn.com.gxrb.client.model.usercenter.ComEntity;
//import cn.com.gxrb.client.model.video.VideoItemBean;
//import cn.com.gxrb.client.module.news.activity.NewsDetailActivity;
//import cn.com.gxrb.client.module.news.activity.NewsVideoActivity;
//import cn.com.gxrb.client.module.news.activity.NewsZhuanTiActivity;
//import cn.com.gxrb.client.module.personal.adapter.CommAdapter;
//import cn.com.gxrb.client.net.Factory;
//import cn.com.gxrb.client.utils.AAnim;
//import cn.com.gxrb.client.utils.LogUtils;
//import cn.com.gxrb.client.utils.ParamUtils;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import butterknife.BindView;
//import rx.android.schedulers.AndroidSchedulers;
//import rx.functions.Action1;
//import rx.functions.Func1;
//import rx.schedulers.Schedulers;
//
//public class CommActivity extends ToolBarActivity {
//    @BindView(R.id.tv_title)
//    TextView tv_title;
//    @BindView(R.id.ptrlistview_activity_comm)
//    PullToRefreshListView ptrlistview_activity_comm;
//    CommAdapter adapter;
//    private int Page = 1;
//    private static final int PageSize = 15;
//    private boolean mFlagRefresh = true;//刷新还是加载
//    private List<ComBean> list;
//
//
//    @Override
//    public int setMyContentView() {
//        return R.layout.activity_comm;
//    }
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        tv_title.setText("我的评论");
//        list = new ArrayList<>();
//        adapter = new CommAdapter(activity);
//        ptrlistview_activity_comm.setAdapter(adapter);
//        ptrlistview_activity_comm.getRefreshableView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
//                mycommItemclick(adapterView, view, i, l);
//            }
//        });
//        ptrlistview_activity_comm.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
//            @Override
//            public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
//                ptrlistview_activity_comm.getLoadingLayoutProxy().setPullLabel("下拉刷新");
//                Page = 1;
//                mFlagRefresh = true;
//                getCommForServer();
//            }
//
//            @Override
//            public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
//                ptrlistview_activity_comm.getLoadingLayoutProxy().setPullLabel("");
//                Page++;
//                mFlagRefresh = false;
//                getCommForServer();
//            }
//        });
//        ptrlistview_activity_comm.postDelayed(new Runnable() {
//            @Override
//            public void run() {
//                ptrlistview_activity_comm.setRefreshing(true);
//            }
//        }, 500);
//    }
//
//    private void mycommItemclick(AdapterView<?> adapterView, View view, int i, long l) {
//        ComBean cb = (ComBean) adapter.getItem(i - 1);
//        Intent intent = new Intent();
//        intent.putExtra("from", "comm");
//        boolean flag = false;//是否是预定类型
//        //跳转脚标）1新闻  2图集  3视频 4html5
//        LogUtils.e("type-->" + cb.getInfo().getRtype());
//
//
//        if ("1".equals(cb.getInfo().getContenttype())) {
//            NewsBean nb = new NewsBean();
//            nb.setNid(cb.getInfo().getContentid());
//            nb.setImgs(cb.getInfo().getImgs());
//            intent.putExtra("newbean", nb);
//            flag = true;
//            intent.setClass(this, NewsDetailActivity.class);
//        } else if ("3".equals(cb.getInfo().getContenttype())) {
//            VideoItemBean nb = new VideoItemBean();
//            nb.setVid(cb.getInfo().getContentid());
//            nb.setTitle(cb.getInfo().getTitle());
//            nb.setVideourl(cb.getInfo().getVideourl());
//            intent.putExtra("videoItemBean", nb);
//            flag = true;
//            intent.setClass(this, NewsVideoActivity.class);
//        } else if ("4".equals(cb.getInfo().getContenttype())) {
//            NewsBean nb = new NewsBean();
//            nb.setNid(cb.getInfo().getContentid());
//            nb.setImgs(cb.getInfo().getImgs());
//            nb.setComflag("1");
//            intent.putExtra("newbean", nb);
//            flag = true;
//            intent.setClass(this, NewsZhuanTiActivity.class);
//        }
//        if (flag) {
//            startActivity(intent);
//            AAnim.startScreen(activity);
//        }
//    }
//
//    private void getCommForServer() {
//        Map<String, String> map = new HashMap<>();
//        map.put("uid", spu.getUser().getUid());
//        map.put("siteid", "1");
//        Factory.provideHttpService().my_comm(ParamUtils.getRequestParam(map))
//                .onBackpressureBuffer()
//                .subscribeOn(Schedulers.io())
//                .filter(new Func1<ComEntity, Boolean>() {
//                    @Override
//                    public Boolean call(ComEntity comentity) {
//                        return true;
//                    }
//                })
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(new Action1<ComEntity>() {
//                    @Override
//                    public void call(ComEntity comentity) {
//                        LogUtils.e("code--" + comentity.code);
//                        ptrlistview_activity_comm.onRefreshComplete();
//                        if ("200".equals(comentity.code)) {
//                            LogUtils.e("code--" + comentity.msg);
//
//
//                            addDataList(comentity.data);
//                            LogUtils.e(list.size() + "");
//                        } else if ("209".equals(comentity.code)) {
//                            adapter.clear();
//                            adapter.removeOld();
//                            list.clear();
//                            adapter.notifyDataSetChanged();
//                        } else {
//                            if (!mFlagRefresh) {
//                                Page--;
//                            }
//                        }
//                        mFlagRefresh = false;
//                    }
//
//                }, new Action1<Throwable>() {
//                    @Override
//                    public void call(Throwable throwable) {
//                        LogUtils.i("throwable--" + throwable.getMessage());
//                    }
//                });
//    }
//
//    private void addDataList(List<ComBean> mlist) {
//        adapter.appendData(mlist, true);
//        LogUtils.e(list.size() + "");
//        adapter.notifyDataSetChanged();
//        ptrlistview_activity_comm.setAdapter(adapter);
//    }
//}
//
